<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>我和领导有话说</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=2.0, user-scalable=no" />
<meta content="telephone=no" name="format-detection"/>
<link href="/Public/projects/option/css/yjxBase.css" type="text/css" rel="stylesheet"/>
</head>
<body style="background-color:#eef3f7">
<h1 class="h1Reply">我的留言</h1>
<!------留言为空---->
<?php if(empty($view_arr)){?>
<div class="blankBox"></div>
<!------留言为空---->
<?php }else{
    echo '<a class="myReply" style="top: 3px;" href="/Wap/Tool/option_view"></a>';
    echo '<div class="divReply">';
   //------留言非空(员工)----
   if($person['level'] == 0){
   foreach($view_arr as $view){
        echo '<div class="divList"><span class="replyName"><span class="spanReply iconfont icon-fasong"></span>';
        echo $person_arr[$view['leader_id']];
        echo '</span><span class="spanTxt">';
        echo $view['content'] . '</span><div class="date">' . $view['created_date'];
        $resp = array();
        foreach($reply_arr as $reply){
            if($reply['view_id'] == $view['view_id']){
                $resp = $reply;
                break;
            }
        }
        if(empty($resp)){
            echo '<div class="delete" onclick="delete_view(' . $view['view_id'] . ')">删除</div>';
        }
        echo '</div>';
        if(!empty($resp)){
            echo '<div class="listReply"><span class="replyIcon iconfont icon-huifu">' . $person_arr[$view['leader_id']] . '：</span>';
            echo '<p>' . $resp['content'] . '</p><div class="date">' . $resp['created_date'] . '</div></div>';
        }
        echo '</div>';
   }
?>
<!------留言非空(员工)---->
<?php }else{
//-----留言非空(领导)----
        foreach($view_arr as $view){
           echo '<div class="divList"><span class="replyName"><span class="spanReply iconfont icon-fasong"></span>';
            if($view['ireal_name']){
                echo '匿名';
            }else{
                echo $person_arr[$view['staff_id']];
            }
            echo '</span><span class="spanTxt">';
            echo $view['content'] . '</span><div class="date">' . $view['created_date'];
            $resp = array();
            foreach($reply_arr as $reply){
                if($reply['view_id'] == $view['view_id']){
                    $resp = $reply;
                    break;
                }
            }
            if(empty($resp)){
                echo '<div class="replyBtn iconfont reply"></div><div class="listReplyBox"><textarea data-view-id="' . $view['view_id']
               . '"class="replyTextArea" placeholder="回复' .
                $person_arr[$view['staff_id']] . ':"></textarea><input type="button" onclick="reply_it(this);" class="replaySumbit" value="提&nbsp;&nbsp;&nbsp;交"/>';
                echo '</div>';
            }
            echo '</div>';
            if(!empty($resp)){
                echo '<div class="listReply"><span class="replyIcon iconfont icon-huifu">我：</span>';
                echo '<p>' . $resp['content'] . '</p><div class="date">' . $resp['created_date'] . '<div class="delete" onclick="delete_resp(' . $resp['resp_id'] . ')">删除</div></div>';
                echo '</div>';
            }
            echo '</div>';
        }
    }
    echo '</div>';
}?>
<!------留言非空(领导)---->
<!------删除---->
<div class="deLetAlert">
	<p>是否确认删除</p>
    <div class="actionBar"><div class="cancel" onclick="cancel();">取消</div><div class="sure" onclick="commit_option();">确认</div></div>
</div>
<!------删除---->
<div class="mask"></div>
<div class="toast" id="toast">成功!</div>
</body>
<script>
    var view_id = 0;
    var resp_id = 0;
    function delete_view(id){
        view_id = id;
        $(".mask").css("display", "block");
        $(".deLetAlert").css("display", "block");
    }
    function delete_resp(id){
        resp_id = id;
        $(".mask").css("display", "block");
        $(".deLetAlert").css("display", "block");
    }
    function cancel() {
        view_id = 0;
        resp_id = 0;
        $(".deLetAlert").css("display", "none");
        $(".mask").css("display", "none");
    }
    function commit_option() {
        $(".deLetAlert").css("display", "none");
        $.ajax({
            type:'get',
            dataType:'json',
            data:{
                view_id: view_id,
                resp_id: resp_id
            },
            url:'/Wap/Tool/option_delete',
            success:function(res){
                $("#toast").css("display", "block");
                setTimeout(function(){
                    $("#toast").css("display", "none");
                    window.location.reload();
                }, 2000);
            }
        });
    }
    function reply_it(obj){
        var content = $(obj).prev().val();
        var view_id = $(obj).prev().attr("data-view-id");
        $.ajax({
            type:'get',
            dataType:'json',
            data:{
                content: content,
                view_id: view_id
            },
            url:'/Wap/Tool/option_reply_add',
            success:function(res){
                window.location.reload();
            }
        });
    }
</script>
<script src="/Public/js/jquery-1.11.0.min.js"></script>
<script src="/Public/projects/option/js/common.js"></script>
<script src="/Public/js/common/baidutongji.js"></script>
</html>
